package com.woniuxy.company5.controller;

import com.woniuxy.company5.dto.LMacInformationDto;
import com.woniuxy.company5.dto.MacInformationDto;
import com.woniuxy.company5.service.MacImgService;
import com.woniuxy.company5.service.MacInformationService;
import com.woniuxy.company5.service.MacListService;
import com.woniuxy.company5.util.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/LmacInformation")
public class LMacInformationController {
    @Resource
    private MacInformationService macInformationService;
    @Resource
    private MacListService macListService;
    @Resource
    private MacImgService macImgService;

    @PostMapping("")
    public Result add(@RequestBody LMacInformationDto macInformationDto){
        //图片id
        int iid = macImgService.insertSelectivel(macInformationDto.getImg1());
        //基本信息表ID
        int did = macInformationService.insertSelectivel(macInformationDto, iid);

        macListService.insertSelective(macInformationDto.getInventory(), did,macInformationDto.getTypeId());
        return Result.ok().data("tupian",iid).data("xinxi",did);
    }
}
